<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>时钟</title>
    <style type="text/css">
        *{
            padding: 0;
            margin: 0;
        }
        .box{
            width: 320px;
            height: 320px;
            position: relative;
            margin: auto;
        }
        #clock{
            width: 100%;
            height: 100%;
            margin: auto;
            background: #ddd;
            list-style: none;
            position: relative;
            margin-top: 100px;
            padding: 20px;
            border-radius: 50%;
            border: 2px solid #333;
        }
        li{
            width: 160px;
            font-size: 30px;
            margin-top: 138px;
            position: absolute;
            transform-origin: right;
        }
        span{
            display: inline-block;
        }
        #hour{
            height: 90px;
            width: 6px;
            position: absolute;
            top: 90px;
            left: 178px;
            background: #f0f;
            transform-origin: bottom;
        }
        #min{
            height: 110px;
            width: 4px;
            position: absolute;
            top: 70px;
            left: 179px;
            background: #ff0;
            transform-origin: bottom;
        }
        #sec{
            height: 130px;
            width: 2px;
            position: absolute;
            top: 50px;
            left: 180px;
            background: darkgreen;
            transform-origin: bottom;
        }
    </style>
    <script type="text/javascript">
        function Clock(a,b,c,d,e){
            this.num=a;
            this.code=b;
            this.hours=c;
            this.min=d;
            this.sec=e;
            this.Road();
            this.Time();
        }
        Clock.prototype.Road=function(){
            for(var i=0;i<12;i++){
                this.num[i].style.transform="rotate("+i*30+"deg)";
                this.code[i].style.transform="rotate(-"+i*30+"deg)";
            }
        }
        Clock.prototype.Time=function(){
            _this=this;
            getTime();
            function getTime(){
                var time = new Date();
                var h = time.getHours(); 
                var m = time.getMinutes();
                var s = time.getSeconds();
                _this.hours.style.transform="rotate("+(h*30+(m*6+s*0.1)/12)+"deg)";
                _this.min.style.transform="rotate("+(m*6+s*0.1)+"deg)";
                _this.sec.style.transform="rotate("+s*6+"deg)";
            }
            setInterval(getTime,1000);
        }
        window.onload=function(){
            var num=document.querySelectorAll('#clock li');
            var code=document.querySelectorAll('#clock li span');
            var hours=document.querySelector("#hour");
            var min=document.querySelector("#min");
            var sec=document.querySelector("#sec");
            var zhong=new Clock(num,code,hours,min,sec);
        }
    </script>
</head>
<body>
    <div class="box">
        <ul id="clock">
            <li><span>9</span></li>
            <li><span>10</span></li>
            <li><span>11</span></li>
            <li><span>12</span></li>
            <li><span>1</span></li>
            <li><span>2</span></li>
            <li><span>3</span></li>
            <li><span>4</span></li>
            <li><span>5</span></li>
            <li><span>6</span></li>
            <li><span>7</span></li>
            <li><span>8</span></li>
        </ul>
        <div id="hour"></div>
        <div id="min"></div>
        <div id="sec"></div>
    </div>
</body>
</html>